﻿using System.Globalization;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xpedite.Minification.YuiCompressor.Config;
using Yahoo.Yui.Compressor;

/* Copyright (c) 2010 CBaxter
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
 * IN THE SOFTWARE. 
 */

namespace Xpedite.Minification.YuiCompressor.Test.Config
{
  [TestClass]
  public class ConfigSectionHandlerTest
  {
    [Ignore]
    [TestMethod]
    public void TestCanParseDefinedConfig()
    {
      var configSection = ConfigSectionHandler.Instance;

      ICssOptions actualCss = configSection.Css;
      Assert.AreEqual(80, actualCss.ColumnWidth);
      Assert.AreEqual(CssCompressionType.Hybrid, actualCss.CompressionType);
      Assert.AreEqual(true, actualCss.RemoveComments);

      IJavaScriptOptions actualJs = configSection.JavaScript;
      Assert.AreEqual(true, actualJs.DisableOptimizations);
      Assert.AreEqual(true, actualJs.IgnoreEval);
      Assert.AreEqual(80, actualJs.LineBreakPosition);
      Assert.AreEqual(false, actualJs.ObfuscateJavascript);
      Assert.AreEqual(true, actualJs.PreserveAllSemicolons);
      Assert.AreEqual(false, actualJs.VerboseLogging);
      Assert.AreEqual(Encoding.UTF8, actualJs.Encoding);
      Assert.AreEqual(CultureInfo.GetCultureInfo("en-CA"), actualJs.ThreadCulture);
    }

    [TestMethod]
    public void TestCanParseMissingConfig()
    {
      var configSection = ConfigSectionHandler.Instance;

      ICssOptions actualCss = configSection.Css;
      Assert.AreEqual(0, actualCss.ColumnWidth);
      Assert.AreEqual(CssCompressionType.StockYuiCompressor, actualCss.CompressionType);

      IJavaScriptOptions actualJs = configSection.JavaScript;
      Assert.AreEqual(false, actualJs.DisableOptimizations);
      Assert.AreEqual(false, actualJs.IgnoreEval);
      Assert.AreEqual(-1, actualJs.LineBreakPosition);
      Assert.AreEqual(true, actualJs.ObfuscateJavascript);
      Assert.AreEqual(false, actualJs.PreserveAllSemicolons);
      Assert.AreEqual(true, actualJs.VerboseLogging);
      Assert.AreEqual(Encoding.Default, actualJs.Encoding);
      Assert.AreEqual(CultureInfo.GetCultureInfo("en-GB"), actualJs.ThreadCulture);
    }
  }
}
